# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=teensy_loader_cli
pkgbase=mingw-w64-${_realname//_/-}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname//_/-}
pkgver=2.2
pkgrel=2
pkgdesc='Command line loader for PJRC Teensy microcontrollers (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=('GPL3')
url='https://www.pjrc.com/teensy/loader_cli.html'
depends=("${MINGW_PACKAGE_PREFIX}-libusb-compat")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=(
    "https://github.com/PaulStoffregen/teensy_loader_cli/archive/${pkgver}/teensy-loader-cli-${pkgver}.tar.gz"
    01-libusb-compat-header.patch
    02-win32-checks.patch
)
sha256sums=(
    '103c691f412d04906c4f46038c234d3e5f78322c1b78ded102df9f900724cd54'
    '8feabd9bb57f6fb6836e5656995340495221e5b94a4af7434f1c7ec504a4d016'
    '05ef2838758d7b98c586c1840052f57eedc79e1e360bf5daba7c4e7e173e8ea4'
)

prepare() {
    cd ${srcdir}/${_realname}-${pkgver}

    patch -p1 -i ../01-libusb-compat-header.patch
    patch -p1 -i ../02-win32-checks.patch
}

build() {
    cd ${srcdir}/${_realname}-${pkgver}

    OS=LINUX make teensy_loader_cli
}

package() {
    cd ${srcdir}/${_realname}-${pkgver}

    install -Dm755 teensy_loader_cli ${pkgdir}${MINGW_PREFIX}/bin/teensy_loader_cli
}
